package cn.t.facade.sku;


import cn.t.constants.ParamConstants;
import cn.t.converter.sku.CustomerSkuDTOConverter;
import cn.t.core.facade.FacadeImpl;
import cn.t.core.mode.PageInfoDTO;
import cn.t.core.mode.PageQueryDTO;
import cn.t.dto.sku.CustomerSkuDTO;
import cn.t.model.sku.CustomerSkuDO;
import cn.t.request.CustomerSkuReq;
import cn.t.service.sku.CustomerSkuService;
import cn.t.vo.sku.CustomerSkuVO;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * 客户商品映射表服务编排
 *
 * @author s
 * @since 2024-06-12
 */
@Slf4j
@Service
@AllArgsConstructor
public class CustomerSkuFacade extends FacadeImpl<CustomerSkuDTO, CustomerSkuDO, CustomerSkuDTOConverter, CustomerSkuService> {
    public PageInfoDTO<CustomerSkuVO> page(PageQueryDTO<CustomerSkuReq> req) {
        List<CustomerSkuDO> list = service.page(req, ParamConstants.GMT_CREATE, ParamConstants.DESC);
        if (CollectionUtils.isEmpty(list)) {
            return new PageInfoDTO<>(req.getPageNo(), req.getPageSize(), 0, null);
        }
        List<CustomerSkuVO> records = this.converter.do2Vo(list);
        return new PageInfoDTO<>(req.getPageNo(), req.getPageSize(), service.queryCustomerSkuCount(req.getParam()), records);
    }
}

